<template>
	<view class="content">
		<headerbox :cixitype="cixi"></headerbox>
		<view class="pages">
			<view class="card">
				<view class="card-body">
					<view class="fromcon">
						<view class="fromitem">
							<view class="icon">
								<image src="../../static/timg/aite.png" mode=""></image>
							</view>
							<input class="input" type="text" placeholder="登陆用户名" v-model="name" />
							<view class="label">登陆用户名</view>
							<view class="right">必须</view>
						</view>
						<view class="fromitem">
							<view class="icon">
								<image src="../../static/timg/xing.png" mode=""></image>
							</view>
							<input class="input" :type="psdtype" placeholder="登陆密码" v-model="psd" />
							<view class="label">登陆密码</view>
							<view class="right-helper">
								<image v-if="psdtype == 'text'" @click="psdtype = 'password'" src="../../static/timg/showpsd.png" mode=""></image>
								<image v-if="psdtype == 'password'" @click="psdtype = 'text'" src="../../static/timg/hidepsd.png" mode=""></image>
							</view>
						</view>
						<view class="fromitem">
							<view class="icon">
								<image src="../../static/timg/xing.png" mode=""></image>
							</view>
							<input class="input" :type="psdtype1" placeholder="确认登陆密码" v-model="comfrimpsd" />
							<view class="label">确认登陆密码</view>
							<view class="right-helper">
								<image v-if="psdtype1 == 'text'" @click="psdtype1 = 'password'" src="../../static/timg/showpsd.png" mode=""></image>
								<image v-if="psdtype1 == 'password'" @click="psdtype1 = 'text'" src="../../static/timg/hidepsd.png" mode=""></image>
							</view>
						</view>
						<view class="fromitem">
							<view class="icon">
								<image src="../../static/timg/zhifupsd.png" mode=""></image>
							</view>
							<input class="input" :type="psdtype2" placeholder="支付密码" v-model="zfpsd" />
							<view class="label">支付密码</view>
							<view class="right-helper">
								<image v-if="psdtype2 == 'text'" @click="psdtype2 = 'password'" src="../../static/timg/showpsd.png" mode=""></image>
								<image v-if="psdtype2 == 'password'" @click="psdtype2 = 'text'" src="../../static/timg/hidepsd.png" mode=""></image>
							</view>
						</view>
						<view class="btn" @click="submit()">提交</view>
					</view>
				</view>
			</view>
		</view>
		<view class="footer-bar" :class="cixi ? '':'footer-bar-detached'">
			<view class="fbitem" @click="goSwichPage('/pages/index/index')">
				<view class="image">
					<image src="../../static/timg/shouye.png" mode=""></image>
				</view>
				<view class="text">首页</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/contract/contract')">
				<view class="image">
					<image src="../../static/timg/heyue.png" mode=""></image>
				</view>
				<view class="text">合约</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/assets')">
				<view class="image">
					<image src="../../static/timg/zichan.png" mode=""></image>
				</view>
				<view class="text">资产</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/claim')">
				<view class="image">
					<image src="../../static/timg/suopei.png" mode=""></image>
				</view>
				<view class="text">索赔</view>
			</view>
		</view>
	</view>
</template>

<script>
	import headerbox from '@/pages/header.vue'
	import { dailiregister } from '../../api/api.js'
	export default{
		components:{
			headerbox
		},
		data(){
			return{
				cixi:false,
				
				psdtype:'password',
				psdtype1:'password',
				psdtype2:'password',
				
				name:'',
				psd:'',
				comfrimpsd:'',
				zfpsd:'',
			}
		},
		onLoad() {
			
		},
		onPageScroll(e) {
			if(e.scrollTop > 0){
				this.cixi = true
			}else{
				this.cixi = false
			}
		},
		methods:{
			submit(){
				if(this.name == ''){
					uni.showToast({
						title: '请输入用户名',
						icon:'error',
						duration: 2000
					});
					return false
				}
				if(this.psd == ''){
					uni.showToast({
						title: '请输入密码',
						icon:'error',
						duration: 2000
					});
					return false
				}
				if(this.comfrimpsd != this.psd){
					uni.showToast({
						title: '两次密码不同',
						icon:'error',
						duration: 2000
					});
					return false
				}
				if(this.zfpsd == ''){
					uni.showToast({
						title: '请输入支付密码',
						icon:'error',
						duration: 2000
					});
					return false
				}
				let datas = {
					name:this.name,
					password:this.psd,
					password_confirmation:this.comfrimpsd,
					qk_pwd:this.zfpsd
				}
				dailiregister(datas).then(res => {
					if(res.data.status.errorCode == 0){
						uni.showToast({
							title: res.data.status.msg,
							icon:'success',
							duration: 2000
						});
						setTimeout(function(){
							uni.navigateBack()
						},1500)
					}else{
						uni.showToast({
							title: res.data.status.msg,
							icon:'error',
							duration: 2000
						});
					}
				}).catch(err => {
					console.log(err)
				})
			},
			goSwichPage(page){
				uni.navigateTo({
					url:page
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	*{
		box-sizing: border-box;
	}
	.content{
		width: 100%;
		min-height: 100vh;
		background-color: #f1f1f7;
		color: #747474 !important;
	}
	.pages{
		padding-top: calc(calc(110rpx + 60rpx) + env(safe-area-inset-top));
		padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
	}
	.card{
		width: 94%;
		margin: 0 auto;
		border-radius: 20rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		word-wrap: break-word;
		margin-bottom: 30rpx;
		overflow: hidden;
		background-color: #fff;
		box-shadow: rgba(0, 0, 0, .35) 0px 30px 60px -30px, rgba(0, 0, 0, .35) 0px -2px 6px 0px inset;
	}
	.card-body{
		z-index: 3;
		flex: 1 1 auto;
		padding: 40rpx;
	}
	.fromcon{
		padding-top: 30rpx;
	}
	.fromitem{
		position: relative;
		margin-bottom: 40rpx;
	}
	.icon{
		position: absolute;
		width: 80rpx;
		height: 106rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.icon image{
		width: 28rpx;
		height: 28rpx;
	}
	.fromitem .input{
		width: 100%;
		height: 106rpx;
		line-height: 102rpx;
		border: 2rpx solid rgba(0, 0, 0, 0.07);
		padding-left: 80rpx;
		padding-right: 30rpx;
		border-radius: 20rpx;
		font-size: 24rpx;
		color: #000;
		outline: 0;
	}
	.label{
		position: absolute;
		top: -10rpx;
		height: 20rpx;
		line-height: 20rpx;
		left: 0;
		font-size: 22rpx;
		text-transform: uppercase;
		font-family: "Nunito", sans-serif;
		font-weight: 700;
		transition: all 250ms ease;
		padding-left: 2px !important;
		padding-right: 5px !important;
		color: #0f1117;
		transform: translateX(80rpx) !important;
		margin-left: -64rpx !important;
	}
	.right{
		position: absolute;
		top: 0px;
		right: 20rpx;
		height: 106rpx;
		line-height: 106rpx;
		pointer-events: none;
		font-size: 20rpx;
		opacity: 0.5;
		color: #747474 !important;
	}
	.right-helper{
		position: absolute;
		top: 0;
		right: 0;
		width: 80rpx;
		height: 106rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.right-helper image{
		width: 28rpx;
		height: 28rpx;
	}
	.btn{
		width: 100%;
		text-align: center;
		margin-bottom: 40rpx;
		margin-top: 60rpx;
		font-weight: 700;
		border-radius: 20rpx;
		font-size: 24rpx;
		padding: 26rpx 40rpx;
		color: #fff;
		border: none;
		background-image: linear-gradient(to bottom, #5D9CEC, #4A89DC);
		background-color: #4A89DC !important;
		box-shadow: 0 10rpx 28rpx 0 rgba(0, 0, 0, 0.1);
		position: relative;
		overflow: visible !important;
		z-index: 10;
	}
	.btn::after{
		transform: scale(0.8) translateY(10rpx) translateZ(0px);
		filter: blur(24rpx);
		content: "";
		position: absolute;
		top: 0px;
		left: 0px;
		width: 100%;
		height: 100%;
		background: inherit;
		z-index: -1;
	}
	
	.footer-bar{
		background-color: rgba(255, 255, 255, 0.95);
		padding: 0px 20rpx;
		position: fixed;
		bottom: 0px;
		left: 0px;
		right: 0px;
		z-index: 98;
		backdrop-filter: blur(20rpx);
		display: flex;
		text-align: center;
		transition: all 250ms ease;
		height: calc(120rpx + env(safe-area-inset-bottom));
		box-shadow: 0 -10rpx 10rpx 0 rgba(0, 0, 0, 0.04);
	}
	.footer-bar.footer-bar-detached{
		border-radius: 40rpx;
		left: 20rpx !important;
		right: 20rpx !important;
		bottom: 30rpx !important;
		box-shadow: 0 0px 30rpx 0 rgba(0, 0, 0, 0.1) !important;
		height: 120rpx !important;
	}
	.fbitem{
		color: #818181;
		position: relative;
		flex: 1 1 auto;
		padding-top: 24rpx;
		
		.image{
			height: 48rpx;
			margin-top: -4rpx;
			
			image{
				width: 36rpx;
				height: 36rpx;
			}
		}
		.text{
			height: 48rpx;
			margin-top: -6rpx;
			font-size: 24rpx;
			opacity: 0.7;
			color: #818181;
		}
	}
</style>